<?php
    error_reporting(0);
    include 'mysqlconnect.php';
    $params = array(
        'hostname' => '127.0.0.1',
        'dbname' => 'level',
        'username' => 'root',
        'password' => ''
    );
    $condition = array();
    
    $time = intval($_GET['year']);
    $type = intval($_GET['type']);
    if ($time != 0)
        $condition['time'] = $time;
    if ($type != 0)
        $condition['case_type_id'] = $type;
    $connect = new mysqlconnect($params);
    $connect->connect();
    $list = $connect->get('cases',array('name_en','name_ch','cases.id','bg_image','time'),$condition,0,0,array('case_relation','cases.id=case_relation.case_id'),null,'asc');
    //$list = $connect->fetch('select name_en,name_ch,cases.id,bg_image from cases join case_relation on cases.id=case_relation.case_id where time=? and case_type_id=?',array($time,$type));
    for($i=0;$i<count($list);$i++)
        $list[$i]['thumbnail'] = 's_'.$list[$i]['bg_image'];
    echo json_encode($list);

?>
